<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>rtclock</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="rspline.html" title="rspline" />
    <link rel="next" href="s16b14.html" title="s16b14" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">rtclock</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="rspline.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="s16b14.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="rtclock"></a>
      <div class="titlepage"></div>
      <a id="IndexRtclock" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">rtclock</span>
        </h2>
        <p>rtclock — 
      Read the real time clock from the operating system.
          </p>
      </div>
      <div class="refsect1">
        <a id="idp143617520"></a>
        <h2>Description</h2>
        <p>
      Read the real-time clock from the operating system.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp143618880"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ires <span class="command"><strong>rtclock</strong></span></pre>
        <pre class="synopsis">kres <span class="command"><strong>rtclock</strong></span></pre>
      </div>
      <div class="refsect1">
        <a id="idp143622240"></a>
        <h2>Performance</h2>
        <p>
      Read the real-time clock from operating system. Under Windows, this changes only once per second. Under GNU/Linux, it ticks every microsecond. Performance under other systems varies.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp143623856"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the rtclock opcode. It uses the file <a class="ulink" href="examples/rtclock.csd" target="_top"><em class="citetitle">rtclock.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp143625632"></a>
          <p class="title">
            <strong>Example 776. Example of the rtclock opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-n     <span class="comment">;;;no sound</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o rtclock.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="comment">;after an example by Iain McCurdy</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1

<span class="opc">FLcolor</span>	200, 200, 200, 0, 0, 0
<span class="comment">;	LABEL     | WIDTH | HEIGHT | X | Y</span>
<span class="opc">FLpanel</span>	"rtclock",   500,    130,    0,  0
<span class="comment">;                                  ON,OFF,TYPE,WIDTH, HEIGHT, X, Y, OPCODE, INS,START,IDUR</span>
gkOnOff,ihOnOff	<span class="opc">FLbutton</span> "On<span class="op">/</span>Off", 1,  0,  22,  150,   25,    5, 5,    0,   1,   0,   3600
gkExit,ihExit	<span class="opc">FLbutton</span> "exitnow",1,  0,  21,  150,   25,  345, 5,    0,  999,  0,   0.001
<span class="opc">FLsetColor2</span> 255, 0, 50, ihOnOff	<span class="comment">;reddish color</span>

<span class="comment">;VALUE DISPLAY BOXES	 WIDTH,HEIGHT,X, Y</span>
gidclock <span class="opc">FLvalue</span> "clock", 100, 25, 200, 60
<span class="opc">FLsetVal_i</span> 1, ihOnOff	
<span class="opc">FLpanel_end</span>
<span class="opc">FLrun</span>

<span class="oblock">instr</span> 1	

<span class="octrl">if</span> gkOnOff <span class="op">!=</span>0 <span class="octrl">kgoto</span> <span class="olabel">CONTINUE</span> <span class="comment">;sense if FLTK on/off switch is not off (in which case skip the next line)  </span>
<span class="opc">turnoff</span>			      <span class="comment">;turn this instr. off now</span>
<span class="olabel">CONTINUE</span><span class="op">:</span>
ktime <span class="opc">rtclock</span>                 <span class="comment">;clock continues to run even </span>
<span class="opc">FLprintk2</span> ktime, gidclock     <span class="comment">;after the on/off button was used to stop</span>

<span class="oblock">endin</span>

<span class="oblock">instr</span> 999

<span class="opc">exitnow</span>			      <span class="comment">;exit Csound as fast as possible</span>

<span class="oblock">endin</span>
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>

<span class="stamnt">f</span> 0 60	<span class="comment">;runs 60 seconds</span>
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp143629920"></a>
        <h2>Credits</h2>
        <p>Author: John ffitch</p>
        <p>New in version 4.10</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="rspline.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="s16b14.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">rspline </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> s16b14</td>
        </tr>
      </table>
    </div>
  </body>
</html>
